//import { getUserFromCookie, getUserFromLocalStorage } from '~/tools/auth'

export default function ({ isServer, store, req,route,redirect,error }) {
  // If nuxt generate, pass this middleware
  // if (isServer && !req) return
  // if(!store.state.user.token){
  //   const loggedUser = isServer ? getUserFromCookie(req) : getUserFromLocalStorage();
  //   console.log('auth',loggedUser,req.session,req.cookies)
  //   store.commit('setuser', loggedUser || {})
  // }
  //console.log(req.cookies,req.session)
  if(!store.state.user.token){
    console.log('no token')
    return redirect('/login?redirect='+route.fullPath)
  }
  
}